<template>
  <div>
    <div class="files-box">
      
      <div class="item" v-for="(item) in fileList" :key="item.fileId">
        <!-- 图片 视频 -->
        <div class="img-box" v-if="$getType(item.type)=='image' || $getType(item.type)=='video'">
          <viewer v-if="$getType(item.type)=='image'">
            <img :src=" item.fileId ? $setUrl(item.url,item.newfilename) : item.url" />
          </viewer>

          <video
            v-if="$getType(item.type)=='video'"
            :src=" item.fileId ? $setUrl(item.url,item.newfilename) : item.url"
            controls
            webkit-playsinline
          ></video>
          <div class="icon">
            <a-icon type="delete" @click="deleteFile(item)" v-if="showDelete" />
          </div>
          <!-- {{$setUrl(item.url,item.newfilename)}} -->
        </div>
        <!-- 文档类型 ppt word 等  v-if="$getType(item.type)=='application' || $getType(item.type)=='text'"-->
        <div class="file-box" v-else>
          <div class="left">
            <a-icon style="font-size:16px" type="file" />
            <div class="name">{{ item.fileId ? `${item.materialName}${item.format}` : item.name}}</div>
          </div>
          <div class="icon">
            <a-icon type="delete" @click="deleteFile(item)" v-if="showDelete" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    fileList: "",
    showDelete: {
      default: true,
    },
  },
  data() {
    return {};
  },
  components: {},
  created() {},
  mounted() {},
  methods: {
    deleteFile(item) {
      this.$emit("FileContentBack", item);
    },
  },
};
</script>
<style lang="less" scoped>
@import "~@/assets/css/base.less";
.files-box {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  .item {
    .img-box {
      margin-right: 20px;
      margin-bottom: 20px;
      display: flex;
      width: 250px;
      height: 150px;
      border: 1px dashed #eee;
      border-radius: 4px;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      img {
        max-width: 250px;
        max-height: 150px;
      }
      video {
        width: 250px;
        height: 150px;
      }
      .icon {
        position: absolute;
        top: 0;
        right: 10px;
        cursor: pointer;
      }
    }
    .file-box {
      border: 1px dashed #eee;
      justify-content: space-between;
      align-items: center;
      display: flex;
      padding: 5px;
      width: 250px;
      height: 50px;
      border-radius: 4px;
      margin-right: 20px;
      margin-bottom: 20px;
      .left {
        justify-content: space-between;
        align-items: center;
        display: flex;
      }
      .name {
        margin-left: 10px;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        overflow: hidden;
        -webkit-box-orient: vertical;
      }
      .icon {
        // position: absolute;
        // top: -1px;
        // right: 10px;
        cursor: pointer;
      }
    }
  }
}
</style>
<style >
</style>